{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# 《神经网络与PyTorch实战》更新与勘误\n",
    "\n",
    "（2018年08月第1版第1次印刷）\n",
    "\n",
    "### 行数计算方法\n",
    "\n",
    "本勘误文档中，行数计算“第$i$行”（$i=0,1,2,\\ldots$）是从0开始计数的。标题、公式、内联代码记入行数，图、表、代码清单及它们的题注不计入行数。空行不计入行数。\n",
    "\n",
    "## 第VI页右栏\n",
    "\n",
    "### 5.1节标题改为\n",
    "\n",
    "单目标线性回归\n",
    "\n",
    "## 第VI页右栏\n",
    "\n",
    "### 5.2节标题改为\n",
    "\n",
    "多目标线性回归\n",
    "\n",
    "## 第49页第6行\n",
    "\n",
    "在某次迭代时$x_{t-1}=1$，这时$\\nabla{f}\\left(x_{t-1}\\right)=-2$\n",
    "\n",
    "### 改为\n",
    "\n",
    "在某次迭代时$x_{t-1}=1$，这时$\\nabla{f}\\left(x_{t-1}\\right)=2$\n",
    "\n",
    "\n",
    "## 第49页第7行\n",
    "\n",
    "在$t+1$次迭代时，$\\nabla{f}\\left(x_t\\right)=2$\n",
    "\n",
    "### 改为\n",
    "\n",
    "在$t+1$次迭代时，$\\nabla{f}\\left(x_t\\right)=-2$\n",
    "\n",
    "## 第60页\n",
    "\n",
    "### 5.1节标题改为\n",
    "\n",
    "单目标线性回归\n",
    "\n",
    "\n",
    "## 第61页第1行\n",
    "\n",
    "$X\\left[:\\right]i,$\n",
    "\n",
    "### 改为\n",
    "\n",
    "$X\\left[:,i\\right]$\n",
    "\n",
    "## 第61页第17行\n",
    "\n",
    "大小为(5,2)的\n",
    "\n",
    "### 作者注：\n",
    "\n",
    "这里的说法不妥。包括常数1的张量`x`大小为(5,3)。如果刨去常数1，大小才是(5,2)。\n",
    "\n",
    "\n",
    "## 第61页、第63页、第71页、第72页\n",
    "\n",
    "`torch.gels`改为`torch.lstsq`。（软件升级，可改可不改。推荐用新API。）\n",
    "\n",
    "## 第62页第13行\n",
    "\n",
    "$=Y\\cdot{Y}-\\left(X\\cdot{W}\\right)-Y\\cdot\\left(X\\cdot{W}\\right)+\\left(X\\cdot{W}\\right.\\cdot\\left(X\\cdot{W}\\right)$\n",
    "\n",
    "### 改为\n",
    "\n",
    "$=Y\\cdot{Y}-\\left(X\\cdot{W}\\right)-Y\\cdot\\left(X\\cdot{W}\\right)+\\left(X\\cdot{W}\\right)\\cdot\\left(X\\cdot{W}\\right)$\n",
    "\n",
    "\n",
    "## 第62页第23行\n",
    "\n",
    "$=\\frac{1}{n}\\left(-2X^{\\top}\\cdot{Y}+X^{\\top}\\cdot\\left(X\\cdot{W}\\right)\\right)$\n",
    "\n",
    "### 改为\n",
    "\n",
    "$=\\frac{1}{n}\\left(-2X^{\\top}\\cdot{Y}+2X^{\\top}\\cdot\\left(X\\cdot{W}\\right)\\right)$\n",
    "\n",
    "\n",
    "## 第63页第4行、第5行、第10行，代码清单5-2题注（共4处）\n",
    "\n",
    "多元线性回归\n",
    "\n",
    "### 改为\n",
    "\n",
    "多目标线性回归\n",
    "\n",
    "\n",
    "## 第83页第6行\n",
    "\n",
    "$p\\left[0\\right]+p\\left[1\\right]+\\cdots+p\\left[c-1\\right]=0$\n",
    "\n",
    "### 改为\n",
    "\n",
    "$p\\left[0\\right]+p\\left[1\\right]+\\cdots+p\\left[c-1\\right]=1$\n",
    "\n",
    "## 第89页代码清单6-8\n",
    "\n",
    "由于软件版本更新，这个代码已经无法运行。更新后的代码见GitHub。\n",
    "\n",
    "## 第89页6.5.2节正文第3行\n",
    "\n",
    "自2012年5月18以来的\n",
    "\n",
    "### 改为\n",
    "\n",
    "自2012年5月18日以来的\n",
    "\n",
    "## 第115页第22行\n",
    "\n",
    "+1=3\n",
    "\n",
    "### 改为\n",
    "\n",
    "+1=5\n",
    "\n",
    "## 第115页第26行\n",
    "\n",
    "1=5\n",
    "\n",
    "### 改为\n",
    "\n",
    "1=7\n",
    "\n",
    "## 第134页第11行\n",
    "\n",
    "因为这个神经网络种\n",
    "\n",
    "### 改为\n",
    "\n",
    "因为这个神经网络中\n",
    "\n",
    "## 第144页第7行\n",
    "\n",
    "其中，$W_{ih}$的大小为$\\left(s_x, 4s_h\\right)$，$W_{ih}$的大小为$\\left(s_h,3s_h\\right)$，\n",
    "\n",
    "### 改为\n",
    "\n",
    "其中，$W_{hh}$的大小为$\\left(s_x, 3s_h\\right)$，$W_{ih}$的大小为$\\left(s_x,3s_h\\right)$，\n",
    "\n",
    "\n",
    "## 第150页代码清单9-6\n",
    "\n",
    "```\n",
    "    test_preds = preds[-test_seq_len]\n",
    "    test_labels = labels[-test_seq_len]\n",
    "```\n",
    "\n",
    "### 改为\n",
    "\n",
    "```\n",
    "    test_preds = preds[train_seq_len:]\n",
    "    test_labels = labels[train_seq_len:]\n",
    "```\n",
    "\n",
    "## 第187页到第188页\n",
    "\n",
    "本书中介绍的PyTorch的安装方法已过时。PyTorch安装方法（2020年12月更新）：\n",
    "https://mp.weixin.qq.com/s/uRx1XOPrfFOdMlRU6I-eyA\n",
    "\n",
    "简而言之，在 Python 3.9 上安装 PyTorch CPU 版本的命令是\n",
    "```\n",
    "conda install pytorch cpuonly -c pytorch -c=conda-forge\n",
    "```"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.8.3"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
